package linkedList.递归.剑指;

import linkedList.BaseLinkedListTest;
import po.ListNode;

/**
 * @author songZiHao
 * @version 1.0.0
 * @ClassName 剑指Offer合并两个排序的链表25.java
 * @Description TODO
 * @createTime 2021年03月22日 10:50:00
 */
public class 剑指Offer合并两个排序的链表25 extends BaseLinkedListTest {

    public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
        if (l1==null){
            return l2;
        }else if (l2==null){
            return l1;
        }else if (l1.val<l2.val){
            ListNode node = mergeTwoLists(l1.next, l2);
            l1.next=node;
            return l1;
        }else {
            ListNode node = mergeTwoLists(l1, l2.next);
            l2.next=node;
            return l2;
        }
    }
}
